package com.shqcjd.yunweiyanoperator.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shqcjd.yunweiyanoperator.R;
import com.shqcjd.yunweiyanoperator.model.pojo.CollectionBean;
import com.shqcjd.yunweiyanoperator.model.pojo.RepairRecordBean;
import com.shqcjd.yunweiyanoperator.util.PrefUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class RepairRecordAdapter extends BaseQuickAdapter<RepairRecordBean.ListBean, RepairRecordAdapter.ViewHolder> {
    private Context context;

    public RepairRecordAdapter(@Nullable List<RepairRecordBean.ListBean> data, Context context) {
        super(R.layout.item_repair_record, data);
        this.context = context;
    }

    @Override
    protected void convert(ViewHolder helper, RepairRecordBean.ListBean item) {
        helper.tvTitle.setText(item.initiatorUserName);
        helper.tvExpert.setText("专家:"+item.acceptUserName);
        helper.tvTime.setText("结束时间:"+item.endTime);
        helper.tvTitle.setText(item.title);
        helper.addOnClickListener(R.id.tv_view_file);
        helper.addOnClickListener(R.id.tv_view_share);
//        if(PrefUtils.getInt(mContext, PrefUtils.USER_TYPE, 1)==1){
//            helper.tvViewShare.setVisibility(View.GONE);
//        }else{
            helper.tvViewShare.setVisibility(View.VISIBLE);
//        }
        if (item.shared==1){
            helper.tvViewShare.setText("已分享");
        }else{
            helper.tvViewShare.setText("分享");
        }
    }

    class ViewHolder extends BaseViewHolder {
        @BindView(R.id.tv_title)
        TextView tvTitle;
        @BindView(R.id.tv_expert)
        TextView tvExpert;
        @BindView(R.id.tv_time)
        TextView tvTime;
        @BindView(R.id.tv_view_file)
        TextView tvViewFile;
        @BindView(R.id.tv_view_share)
        TextView tvViewShare;
        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
